﻿elector_voting_pattern_circumstances_mahestan_elective_modifier = {
	##########################	Elector voting patterns (circumstances)	##########################
	#Sexism
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_agnatic_woman
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = male_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = male_preference_law }
				scope:title = {
					NOR = {
						has_title_law = female_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_male_dominated }
		}
		scope:candidate = { is_female = yes }
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = male_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = male_preference_law }
							scope:title = {
								NOR = {
									has_title_law = female_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_male_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	modifier = { #Gender weights
		desc = tooltip_feudal_elector_vote_enatic_man
		OR = {
			scope:title = { #Title might have different law than realm's.
				has_title_law = female_preference_law
			}
			AND = { #If title has neither the required law nor its opposites, check for realm law.
				scope:holder = { has_realm_law = female_preference_law }
				scope:title = {
					NOR = {
						has_title_law = male_preference_law
						has_title_law = equal_law
					}
				}
			}
			faith = { has_doctrine = doctrine_gender_female_dominated }
		}
		scope:candidate = {
			is_female = no
		}
		add = {
			subtract = 100
			if = { #Increase if both.
				limit = {
					OR = {
						scope:title = { #Title might have different law than realm's.
							has_title_law = female_preference_law
						}
						AND = { #If title has neither the required law nor its opposites, check for realm law.
							scope:holder = { has_realm_law = female_preference_law }
							scope:title = {
								NOR = {
									has_title_law = male_preference_law
									has_title_law = equal_law
								}
							}
						}
					}
					faith = { has_doctrine = doctrine_gender_female_dominated }
				}
				multiply = 1.5
			}
			if = { #Halve if talking about myself.
				limit = {
					this = scope:candidate
					scope:candidate = scope:holder_candidate
				}
				multiply = 0.5
			}
		}
	}
	#Ageism
	modifier = {
		add = -30
		desc = tooltip_feudal_elector_vote_baby
		NOT = { this = scope:candidate }
		scope:candidate = {
			age < 5
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_child
		NOT = { this = scope:candidate }
		scope:candidate = {
			age > 5
			age < 16
		}
		add = {
			subtract = 10
			if = {
				limit = {
					age < 10
				}
				subtract = 15
			}
		}
	}
	modifier = { #Still too young for older rulers
		add = -10
		desc = tooltip_feudal_elector_vote_youngster
		NOT = { this = scope:candidate }
		age > 40
		scope:candidate = {
			age > 16
			age < 25
		}
	}
	modifier = { #Or too old for younger rulers.
		add = -10
		desc = tooltip_feudal_elector_vote_oldtimer
		NOT = { this = scope:candidate }
		age < 30
		scope:candidate = {
			age > 40
			age < 50
		}
	}
	modifier = { #Or simply too old overall.
		add = -15
		desc = tooltip_feudal_elector_vote_decrepit
		NOT = { this = scope:candidate }
		scope:candidate = { age > 50 }
	}
	#Culturism
	modifier = {
		desc = tooltip_feudal_elector_vote_fellow_culture
		NOT = { this = scope:candidate }
		root.culture = scope:candidate.culture
		add = {
			add = 10
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				add = 10
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_stranger
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { root.culture = scope:candidate.culture }
		culture = { has_same_culture_heritage = scope:candidate.culture }
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 15
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 15
			}
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_foreigner
		scope:holder.culture = root.culture #Only a concern if Elector and current ruler share culture.
		NOT = { culture = { has_same_culture_heritage = scope:candidate.culture } }
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 30
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 30
			}
		}
	}
	modifier = { #Candidate is a foreigner's pet
		desc = tooltip_feudal_elector_vote_strangers_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { this.culture = root.culture }
			culture = { has_same_culture_heritage = root.culture }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 10
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 10
			}
		}
	}
	modifier = { #Candidate is a foreigner's pet
		desc = tooltip_feudal_elector_vote_foreigners_pet
		scope:candidate = {
			this = scope:holder_candidate
			NOT = { culture = { has_same_culture_heritage = root.culture } }
			this.culture = scope:holder.culture
		}
		NOT = { is_close_family_of = scope:candidate }
		add = {
			subtract = 15
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 15
			}
		}
	}
	modifier = { #If candidate is elected, he will rule from a capital outside this de jure.
		desc = tooltip_feudal_elector_vote_political_concerns
		is_landed = yes
		exists = capital_county
		capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } }

		OR = { # If the current holder is reigning from within the title, there is no reason to believe a lower tier candidate would not.
			scope:holder = { 
				capital_county = {
					scope:title = {
						NOT = { is_de_jure_liege_or_above_target = prev }
					}
				}
			}
			scope:candidate = {
				highest_held_title_tier >= scope:title.tier
			}
		}

		scope:candidate = {
			is_ruler = yes
			is_vassal_of = scope:holder
			exists = capital_county
			NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
		}
		add = {
			subtract = 15
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 15
			}
		}
	}
	modifier = { #Candidate is a foreign ruler.
		desc = tooltip_feudal_elector_vote_encroaching_foreigner
		is_landed = yes
		exists = capital_county
		scope:candidate = {
			is_ruler = yes
			NOT = { target_is_liege_or_above = scope:holder }
		}
		add = {
			subtract = 30
			if = { #Candidate is a foreign non-dejure ruler.
				limit = {
					NOT = { capital_county = { scope:title = { is_de_jure_liege_or_above_target = prev } } }
				}
				subtract = 470
			}
			if = { #Boost for Scandinavian Elective.
				limit = {
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				subtract = 50
			}
		}
	}
	#Faithism
	modifier = { #Accepted but different faith. (Buddhism vs Hinduism)
		desc = tooltip_feudal_elector_vote_different_faith
		NOT = { root.faith = scope:candidate.faith }
		ai_zeal >= 0 #Does not care otherwise.
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_fully_accepted_level
			}
		}
		add = {
			subtract = 25
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 25
			}
		}
	}
	modifier = { #Astray (Catholic vs Orthodox)
		desc = tooltip_feudal_elector_vote_astray
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_astray_level
			}
		}
		add = {
			subtract = 50
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 50
			}
		}
	}
	modifier = { #Heretic (Catholic vs Cathar)
		desc = tooltip_feudal_elector_vote_heretic
		add = {
			subtract = 100
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 50
			}
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 100
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_hostile_level
			}
		}
	}
	modifier = { #Infidel (Catholic vs Ashari)
		desc = tooltip_feudal_elector_vote_evil_heathen
		add = {
			subtract = 200
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= low_positive_zeal
				}
				subtract = 75
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= medium_positive_zeal
				}
				subtract = 75
			}
			if = { #Further increased by AI zeal.
				limit = {
					ai_zeal >= high_positive_zeal
				}
				subtract = 75
			}
			if = { #Further increased for Princely Elective.
				limit = {
					scope:title = { has_title_law = princely_elective_succession_law }
				}
				subtract = 150
			}
		}
		NOT = { root.faith = scope:candidate.faith }
		faith = {
			faith_hostility_level = {
				target = scope:candidate.faith
				value = faith_evil_level
			}
		}
	}

	#Barbarism
	modifier = {
		add = -15
		desc = tooltip_feudal_elector_vote_uncivilized
		OR = {
			government_has_flag = government_is_feudal
			has_government = republic_government
		}
		scope:candidate = {
			OR = {
				government_has_flag = government_is_clan
				government_has_flag = government_is_tribal
			}
		}
	}
	modifier = {
		add = -15
		desc = tooltip_feudal_elector_vote_settled
		government_has_flag = government_is_clan
		scope:candidate = {
			NOT = { government_has_flag = government_is_clan }
		}
	}
	#Nepotism
	modifier = {
		add = 25
		desc = tooltip_feudal_elector_vote_dynasty
		NOT = { this = scope:candidate }
		exists = root.dynasty
		exists = scope:candidate.dynasty
		root.dynasty = scope:candidate.dynasty
		scope:candidate = {
			NOT = { is_close_family_of = root }
		}
	}
	modifier = {
		add = 50
		desc = tooltip_feudal_elector_vote_relative
		NOT = { this = scope:candidate }
		scope:candidate = {
			is_close_family_of = root
			NOT = { is_child_of = root }
		}
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_parent
		NOT = { this = scope:candidate }
		scope:candidate = { is_child_of = root }
		add = {
			value = 70
			if = { #Current Ruler should tend to often pick one of his own children as potential heirs.
				limit = { this = scope:holder }
				add = 30
			}
		}
	}
	modifier = { #Elector AI should not pick current ruler's distant relatives
		add = -200
		desc = tooltip_feudal_elector_vote_distant_relative
		NOR = {
			this = scope:candidate
			is_close_family_of = root
			scope:candidate = scope:holder_candidate #Avoid if he's being specifically picked by the current ruler.
		}
		exists = scope:candidate.dynasty
		exists = scope:holder.dynasty
		scope:candidate = { #Candidate in question must not be of the same house as the Elector.
			dynasty = scope:holder.dynasty
			NOT = {
				house = root.house
			}
		}
	}
	#Educational preferences
	modifier = { # Warrior society prefers warriors
		desc = tooltip_feudal_elector_vote_martial_education
		this_is_martial_society_trigger = yes
		scope:candidate = {
			martial >= 10
			OR = {
				has_trait = education_martial
				has_lifestyle = martial_lifestyle
				has_trait = lifestyle_blademaster
				has_martial_lifestyle_trait_trigger = yes
			}
		}
		add = {
			add = 15
			if = {
				limit = { # Scandinavian elective boost
					scope:title = { has_title_law = scandinavian_elective_succession_law }
				}
				multiply = 2
			}
		}
	}
	modifier = { # Diplomatic society prefers stewards and diplomats
		add = 15
		desc = tooltip_feudal_elector_vote_diplomatic_education
		this_is_diplomatic_society_trigger = yes
		scope:candidate = {
			OR = {
				AND = {
					diplomacy >= 10
					OR = {
						has_trait = education_diplomacy
						has_lifestyle = diplomacy_lifestyle
						has_diplomacy_lifestyle_trait_trigger = yes
						has_trait = lifestyle_reveler
						has_trait = gallant
					}
				}
				AND = {
					stewardship >= 10
					OR = {
						has_trait = education_stewardship
						has_lifestyle = stewardship_lifestyle
						has_stewardship_lifestyle_trait_trigger = yes
					}
				}
			}
		}
	}
	modifier = { # Spiritual society prefers scholars
		add = 15
		desc = tooltip_feudal_elector_vote_spiritual_education
		this_is_spiritual_society_trigger = yes
		scope:candidate = {
			learning >= 10
			OR = {
				has_trait = education_learning
				has_lifestyle = learning_lifestyle
				has_learning_lifestyle_trait_trigger = yes
				has_trait = lifestyle_mystic
				has_trait = lifestyle_physician
			}
		}
	}
	#Claims
	modifier = {
		add = 30
		desc = tooltip_feudal_elector_vote_strong_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_claim_on = scope:title }
	}
	modifier = {
		add = 15
		desc = tooltip_feudal_elector_vote_weak_claimant
		NOT = { this = scope:candidate }
		scope:candidate = { has_weak_claim_on = scope:title }
	}
}
elector_voting_pattern_prestige_piety_mahestan_elective_modifier = {
	##########################	Elector voting patterns (prestige/piety)	##########################
	#Prestige
	modifier = {
		desc = tooltip_feudal_elector_vote_prestige_negative
		add = -20
		NOT = { this = scope:candidate }
		scope:candidate = { prestige_level < 1 }
	}
	modifier = {
		desc = tooltip_feudal_elector_vote_prestige_positive
		add = {
			value = scope:candidate.prestige_level
			subtract = 1
			multiply = 5
		}
		NOT = { this = scope:candidate }
		scope:candidate = { prestige_level >= 2 }
	}
	#Dynasty Prestige
	modifier = {
		desc = tooltip_feudal_elector_vote_dynasty_prestige
		add = {
			value = 20
			if = {
				limit = {
					scope:candidate.dynasty = { dynasty_prestige_level >= 10 }
				}
				add = 20
			}
			if = {
				limit = {
					scope:candidate.dynasty = { dynasty_prestige_level >= 7 }
				}
				add = 20
			}
		}
		NOT = { this = scope:candidate }
		exists = scope:candidate.dynasty
		scope:candidate.dynasty = {
			dynasty_prestige_level >= 4
		}
	}
	#Piety
	modifier = { #More extreme for Mahestan Elective
		desc = tooltip_feudal_elector_vote_piety_negative
		scope:title = { has_title_law = mahestan_elective_succession_law }
		add = -30
		NOT = { this = scope:candidate }
		ai_zeal > -30
		scope:candidate = { piety_level < 1 }
	}
	modifier = { #More extreme for Mahestan Elective
		desc = tooltip_feudal_elector_vote_piety_positive
		scope:title = { has_title_law = mahestan_elective_succession_law }
		add = {
			value = scope:candidate.piety_level
			subtract = 1
			multiply = 10
		}
		NOT = { this = scope:candidate }
		faith = scope:candidate.faith
		ai_zeal > -30
		scope:candidate = { piety_level >= 2 }
	}
}